<template>
  <div class="index-news-detail clearfix">
    <div class="location box">
      <router-link to="/cooperation">{{$t('common.nav.cooperation')}}</router-link> >
      <router-link :to="toLink">{{curListName}}</router-link> >
      {{$t('news.detail')}}
    </div>
    <div class="box clearfix">
      <div class="content">
        <!-- 新闻标题 -->
        <div class="news-tit tc font22">{{con.title}}</div> 
        <div class="time tc h88">{{$t('news.releaseTime')}}：{{con.updateTime || con.createTime}}</div>
        <div class="con" v-html="con.content"></div>
      </div>
    </div>
  </div>
</template>
<script>
import {ajax,showToast} from '@/utils/js.js'
import { mainCooperationDetail } from '@/services/api.js'
const log = console.log
export default {
  components:{},
  data() {
    return {
      type:0,
      toLink:'',
      con:{
        
      },
      id:'', //文章id
    }
  },
  mounted(){
    
    let data = this.$route.query
    log(data)
    this.content(data.id)
    this.type = data.type;
    this.id = data.id;
    this.toLink = "/cooperation"
  },
  computed:{
    nav(){
      let data=[
        {name:this.$t('news.schooleHz'),id:0},
        {name:this.$t('news.companyHz'),id:1},
        {name:this.$t('news.joinCompany'),id:1}
      ]
      return data
    },
    curListName(){
      return this.nav[this.type].name;
    }
  },
  watch:{
    '$i18n.locale'(){
      this.content()
    },
  },
  methods:{
    tab(e){
      this.type = e.id
      
    },
    content(id = this.id){
      ajax(this,mainCooperationDetail,{id},res=>{
        this.con = res.data;
        if(this.$route.query.list == 0){
          this.curListName = this.nav[this.type].name
          this.toLink = '/cooperation_list?type=' + this.type
        }
        
      },err=>{
        showToast(this,err.msg)
      })
    },
    //首页跳转
    indexLink(data){
     if(data.outLink && data.outLink==1){
        window.open(data.linkUrl,'-blank')
      }else{
        window.location.href = data.linkUrl
      }
    },
    
  }
}
</script>
<style lang="scss">
  .index-news-detail{
    .content{
      padding:40px 120px;
      background-color: #fff;
      .time{
        padding: 20px 0;
      }
      .con{line-height: 1.8;color: #666;}
    }
    .content{min-height:450px;}
    
  }
</style>